package torchtools.io;

import java.awt.image.BufferedImage;
import java.util.Iterator;
import java.util.List;

/**
 * Describes a Torchlight Imageset file which contains icons.
 * 
 * @author Matt
 */
public class TLImageSet {

    public static final String FILE_EXT = "imageset";
    
    public final BufferedImage Sheet;

    public final String Name;
    public final String Imagefile;
    public final int NativeHorzRes;
    public final int NativeVertRes;
    public final boolean AutoScaled;

    public final String ImagefilePNG;
    List<TLIcon> icons;

    public TLImageSet(BufferedImage Sheet, String Name, String Imagefile, 
                    int NativeHorzRes, int NativeVertRes, 
                    boolean AutoScaled, String ImagefilePNG, List<TLIcon> icons) {
        this.Sheet = Sheet;
        this.Name = Name;
        this.Imagefile = Imagefile;
        this.NativeHorzRes = NativeHorzRes;
        this.NativeVertRes = NativeVertRes;
        this.AutoScaled = AutoScaled;
        this.ImagefilePNG = ImagefilePNG;
        this.icons = icons;
    }
    
    public Iterator<TLIcon> icons() {
        return icons.iterator();
    }
    
    public TLIcon getIcon(int index) {
        return icons.get(index);
    }
    
    public int getIconCount() {
        return icons.size();
    }

    public TLIcon getIcon(String name) {
        for (int i=0; i<icons.size(); i++)
            if (icons.get(i).Name.equals(name))
                return icons.get(i);
        return null;
    }     
}